package weight;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.HorizontalScrollView;

/**
 * ltx on 2016/11/16 09:28
 * 横向移动的距离监听
 */
public class MyHroScrollView extends HorizontalScrollView {

    private ScrollViewListener scrollViewListener = null;
    public MyHroScrollView(Context context) { super(context); }
    public MyHroScrollView(Context context, AttributeSet attrs, int defStyle)
    { super(context, attrs, defStyle); }
    public MyHroScrollView(Context context, AttributeSet attrs)
    { super(context, attrs); }
    public void setScrollViewListener(ScrollViewListener scrollViewListener)
    { this.scrollViewListener = scrollViewListener; }
    protected void onScrollChanged(int x, int y, int oldx, int oldy)
    { super.onScrollChanged(x, y, oldx, oldy);
        if (scrollViewListener != null) { scrollViewListener.onScrollChanged(this, x, y, oldx, oldy); } }

    public interface ScrollViewListener { void onScrollChanged(MyHroScrollView scrollView, int x, int y, int oldx, int oldy); }
}
